﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Conversion_Script
{
    class ArrayOperations
    {

        public static int MaxValue(int[] a)
        {
            int Max = int.MinValue;
            for (int v = 0; v < a.Length; v++)
            {
                if (a[v] > Max) Max = a[v];
            
            }
            return Max;
        }
        public static string[] Remove(string[] a, int index)
        {
            List<string> n = new List<string>();
            
            for (int v = 0; v < a.Length;v++ )
            {
                if (v == index) continue;
                else n.Add(a[v]);
                 
            }

            return n.ToArray();
        }
        
        public static bool IsIdentical(string[] a, string[] b)
        {
            
            for (int v = 0; v < a.Length;v++ )
            {
                if (b[v] != a[v]) return false;
            }
            return true;
           
        }

        public static float[] StringToFloat(string[] a)
        {
            float[] Cumulative = new float[a.Length];

            for (int v = 0; v < a.Length; v++)
            {
                float value;
                if (float.TryParse(a[v], out value) == false)
                {
                    throw new System.Exception("Cannot convert string to float array");
                }
                Cumulative[v] = value;
            }

            return Cumulative;
        }
        public static int[] StringToInt(string[] a)
        {
            int[] Cumulative = new int[a.Length];
            
            for (int v = 0; v < a.Length;v++ )
            {
                int value;
                if(int.TryParse(a[v],out value)== false)
                {
                    throw new System.Exception("Cannot convert string to int array");
                }
                Cumulative[v] = value;
            }

            return Cumulative;
        }

        public static int[] Cumulative(int[] a)
        {
            int[] Cumulative = new int[a.Length];
            int sum = 0;
            for (int v = 0; v < a.Length;v++ )
            {
                sum +=  a[v];
                Cumulative[v] = sum;
            }

            return Cumulative;
        }
        public static float[] Cumulative(float[] a)
        {
            float[] Cumulative = new float[a.Length];
            float sum = 0;
            for (int v = 0; v < a.Length; v++)
            {
                sum += a[v];
                Cumulative[v] = sum;
            }

            return Cumulative;
        }
        public static int Sum(int[] a)
        {
            int sum = 0;
            foreach (int i in a) sum += i;
            return sum;
        }
        public static float Sum(float[] a)
        {
            float sum = 0;
            foreach (float i in a) sum += i;
            return sum;

        }
    }
}
